#include <catch2/catch.hpp>

#include <algorithm>

#include "solution.hpp"

using namespace solution_022;

TEST_CASE("22. Generate Parentheses", "[022]") {

SECTION("example 1") {
    auto parens = Solution().generateParenthesis(3);
    std::sort(parens.begin(), parens.end());
    auto ans = std::vector<std::string>{"((()))","(()())","(())()","()(())","()()()"};
    CHECK(parens.size() == ans.size());
    for (auto i = parens.cbegin(), j = ans.cbegin(); i != parens.cend(); ++i, ++j)
        CHECK(*i == *j);
}

SECTION("example 2") {
    auto parens = Solution().generateParenthesis(4);
    std::sort(parens.begin(), parens.end());
    auto ans = std::vector<std::string>{
            "(((())))",
            "((()()))",
            "((())())",
            "((()))()",
            "(()(()))",
            "(()()())",
            "(()())()",
            "(())(())",
            "(())()()",
            "()((()))",
            "()(()())",
            "()(())()",
            "()()(())",
            "()()()()"};
    CHECK(parens.size() == ans.size());
    for (auto i = parens.cbegin(), j = ans.cbegin(); i != parens.cend(); ++i, ++j)
        CHECK(*i == *j);
}

}
